package com.heima.article.service.impl;


import com.heima.apis.behavior.IBehaviorClient;
import com.heima.article.service.UnLikesBehaviorService;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.utils.thread.ApThreadLocalUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author yht
 * @date 2022/1/15 16:30
 */
@Service
@Slf4j
@Transactional
public class UnLikesBehaviorServiceImpl implements UnLikesBehaviorService {
    @Autowired
    private IBehaviorClient iBehaviorClient;

    /**
     * 不喜欢
     * @param dto
     * @return
     */
    @Override
    public ResponseResult unLikesBehavior(UnLikesBehaviorDto dto) {
        Integer id = ApThreadLocalUtils.getUser().getId();
        dto.setUserId(id);
        ResponseResult responseResult = iBehaviorClient.unLikes(dto);
        if(responseResult.getCode()!=200){
            ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR,"远程调用失败");
        }
        return responseResult;
    }
}
